var t = getApp();

Page({
    data: {
        active: 0,
        listData: [],
        activeChild: 0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "众筹活动"
        });
    },
    init: function() {
        this.setData({
            listData: [],
            isLoadMore: [],
            page: 1,
            total_page: 0,
            activeChild: 0
        });
    },
    changeTap: function(t) {
        this.setData({
            active: t.detail.index
        }), this.init(), this.getData();
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    getChildIndex: function(t) {
        this.init(), this.data.activeChild = t.detail, this.getData();
    },
    getData: function() {
        var a, i = this, e = {
            page: this.data.page
        };
        if (0 != this.data.active) switch (this.data.activeChild) {
          case 1:
            e.status = 0;
            break;

          case 2:
            e.status = 1;
            break;

          case 3:
            e.status = 2;
            break;

          default:
            e.status = "";
        }
        0 == this.data.active ? (a = "plugin.crowdfunding.frontend.activity-member.selfPaid", 
        e.status = "") : a = 1 == this.data.active ? "plugin.crowdfunding.frontend.activity-member.crowdfunding" : "plugin.crowdfunding.frontend.activity-member.support", 
        a = t.getNetAddresss(a), t._getNetWork({
            url: a,
            data: e,
            success: function(t) {
                var a = t.data;
                1 == a.result && (i.data.isLoadMore = !0, i.data.total_page = a.data.last_page, 
                i.data.total_page || (i.data.total_page = 0), i.setData({
                    listData: a.data.data
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMore: function() {
        var a = this, i = "";
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var e = {
                page: this.data.page
            };
            if (0 != this.data.active) switch (this.data.activeChild) {
              case 1:
                e.status = 0;
                break;

              case 2:
                e.status = 1;
                break;

              case 3:
                e.status = 2;
                break;

              default:
                e.status = "";
            }
            i = 0 == this.data.active ? "plugin.crowdfunding.frontend.activity-member.selfPaid" : 1 == this.data.active ? "plugin.crowdfunding.frontend.activity-member.crowdfunding" : "plugin.crowdfunding.frontend.activity-member.support", 
            t._postNetWork({
                url: i,
                data: e,
                success: function(t) {
                    var i = t.data;
                    1 == i.result ? (a.data.isLoadMore = !0, a.setData({
                        listData: a.data.listData.concat(i.data.data)
                    })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: i.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});